<?php namespace Home\Controller; 
use Hdphp\Controller\Controller;
/**
 *  详情页控制器
 */
class ContentsController extends Controller{
    	//显示页
    	public function index(){
		$aid = Q('get.aid',0,'intval');
		//查出文章信息
		$arcModel = new \Common\Model\Article();
		$arcTagModel = new \Common\Model\ArticleTag();
                        $comment = new  \Common\Model\Comment();
		
		//点击量加+1
		$arcModel->where(array('aid'=>$aid))->increment('click');
		
		//文章信息
		$arcData = $arcModel->join('article_data','article_aid','=','aid')->where(array('aid'=>$aid))->find();
                        
                        //文章评论
                        $total = $comment->where(array('article_aid'=>$aid))->count();
                        //定制分页样式
                        $page = Page::row(2)->desc(array('pre'=>'← Previous', 'next'=>'Next → '))->make($total);
                        $comData = $comment->where(array('article_aid'=>$aid))->limit(Page::limit())->get();
                        if ($comData) {
                                  $this->assign('page', $page);
                                  $this->assign('total', $total);
                        }
                        $cData = empty($comData) ? array() : $comData;
                        $this->assign('cData', $cData);
		//文章标签
		$tagData = $arcTagModel->join('tag','tag_tid','=','tid')->where(array('article_aid'=>$aid))->lists('tid,tname');
		$this->assign('arcData',$arcData);
		$this->assign('tagData',$tagData);

		$this->display();
    	}
        
        
}
